-- ZS Naplneni udaje Energeticky pausal v Konfiguraci mezd (NESPOUSTET)
<g>
  UPDATE a450391u10 SET a42658307u10 = 2300 WHERE (a546181u10 >= '2025-12-01') AND a42658307u10 IS NULL
</g>
<g>
  UPDATE a450391u10 SET a42658307u10 = 0 WHERE a42658307u10 IS NULL
</g>
-- ZS konec

-- ZS Vymaz udaje "% povinny prispevek" v Konfiguraci mezd (NESPOUSTET)
<g>
  UPDATE a450391u10 SET a12685418u10 = NULL WHERE (a546181u10 < '2026-1-01')
</g>
<g>
  UPDATE a450391u10 SET a12685418u10 = 4 WHERE (a546181u10 >= '2026-1-01') AND a12685418u10 IS NULL
</g>
-- ZS konec

--MaSu: Plnění pomocných tříd z objektů workflow (NESPOUŠTĚT)
<g>
  declare @ica bigint
  declare @ua int
  declare @icb bigint
  declare @ub int
  declare @ic bigint
  declare @u int
  select @u = a15832u10 from a15830u10
-- třída "Akce objektu workflow"
  declare AkceObjektuWF scroll cursor for select a.ic,a.u,a.a41471625u10,a.a41471627u10 from a41471624u10 as a 
  inner join a4222u10 as b on a.a41471625u10 = b.ic and a.a41471627u10 = b.u 
  left join a42675869u10 as c on a.ic = c.ic_a and a.u = c.u_a and b.ic = c.ic_b and b.u = c.u_b 
  where a.u = @u and c.ic is null
  open AkceObjektuWF
  fetch first from AkceObjektuWF into @ica, @ua, @icb, @ub
  while (@@fetch_status = 0)
  begin
    insert into dbo.icseq (u) values (0)
    set @ic = @@identity
      <p>
      insert into a42675869u10 (ic,u,ts0,useric,useru,langstate,ic_a,u_a,ic_b,u_b) values (@ic,@u,GetDate(),1105,0,1,@ica,@ua,@icb,@ub)
      </p>
      <a>
      insert into a42675869u10 (ic,u,ts0,useric,useru,langstate,ic_a,u_a,ic_b,u_b,sstate,sstate_a,sstate_b) values (@ic,@u,GetDate(),1105,0,1,@ica,@ua,@icb,@ub,0,0,0)
      </a>
      delete from dbo.icseq where (ic = @ic) and (u = 0) 
   fetch next from AkceObjektuWF into @ica, @ua, @icb, @ub
  end
  close AkceObjektuWF
  deallocate AkceObjektuWF

-- třída "Informace objektu workflow"
  declare InformaceObjektuWF scroll cursor for select a.ic,a.u,a.a41471625u10,a.a41471627u10 from a41471624u10 as a 
  inner join a231811u10 as b on a.a41471625u10 = b.ic and a.a41471627u10 = b.u 
  left join a42675870u10 as c on a.ic = c.ic_a and a.u = c.u_a and b.ic = c.ic_b and b.u = c.u_b 
  where a.u = @u and c.ic is null
  open InformaceObjektuWF
  fetch first from InformaceObjektuWF into @ica, @ua, @icb, @ub
  while (@@fetch_status = 0)
  begin
    insert into dbo.icseq (u) values (0)
    set @ic = @@identity
      <p>
      insert into a42675870u10 (ic,u,ts0,useric,useru,langstate,ic_a,u_a,ic_b,u_b) values (@ic,@u,GetDate(),1105,0,1,@ica,@ua,@icb,@ub)
      </p>
      <a>
      insert into a42675870u10 (ic,u,ts0,useric,useru,langstate,ic_a,u_a,ic_b,u_b,sstate,sstate_a,sstate_b) values (@ic,@u,GetDate(),1105,0,1,@ica,@ua,@icb,@ub,0,0,0)
      </a>
      delete from dbo.icseq where (ic = @ic) and (u = 0) 
   fetch next from InformaceObjektuWF into @ica, @ua, @icb, @ub
  end
  close InformaceObjektuWF
  deallocate InformaceObjektuWF

-- třída "Subjekt objektu workflow"
  declare SubjektObjektuWF scroll cursor for select a.ic,a.u,a.a41471625u10,a.a41471627u10 from a41471624u10 as a 
  inner join a130u0 as b on a.a41471625u10 = b.ic and a.a41471627u10 = b.u 
  left join a42675871u10 as c on a.ic = c.ic_a and a.u = c.u_a and b.ic = c.ic_b and b.u = c.u_b 
  where a.u = @u and c.ic is null
  open SubjektObjektuWF
  fetch first from SubjektObjektuWF into @ica, @ua, @icb, @ub
  while (@@fetch_status = 0)
  begin
    insert into dbo.icseq (u) values (0)
    set @ic = @@identity
      <p>
      insert into a42675871u10 (ic,u,ts0,useric,useru,langstate,ic_a,u_a,ic_b,u_b) values (@ic,@u,GetDate(),1105,0,1,@ica,@ua,@icb,@ub)
      </p>
      <a>
      insert into a42675871u10 (ic,u,ts0,useric,useru,langstate,ic_a,u_a,ic_b,u_b,sstate,sstate_a,sstate_b) values (@ic,@u,GetDate(),1105,0,1,@ica,@ua,@icb,@ub,0,0,0)
      </a>
      delete from dbo.icseq where (ic = @ic) and (u = 0) 
   fetch next from SubjektObjektuWF into @ica, @ua, @icb, @ub
  end
  close SubjektObjektuWF
  deallocate SubjektObjektuWF
</g>

-- TB - update druhů výrobních zakázek (NESPOUŠTĚT)
<g>
  UPDATE druh
  SET druh.a42661458u10 = 1
  FROM a2230330u10 AS druh
  INNER JOIN a2338069u10 AS dvz ON 
  druh.ic = dvz.ic AND druh.u = dvz.u
  WHERE druh.a2518973u10 = 3
</g>
-- TB - konec

-- TB - update výrobních zakázek (NESPOUŠTĚT)
<g>
  UPDATE akce
  SET akce.a42660775u10 = 1
  FROM a4222u10 AS akce
  INNER JOIN a289647u10 AS zak ON akce.ic = zak.ic AND akce.u = zak.u
  INNER JOIN a2230337u10 AS dv ON dv.ic_a = zak.ic AND dv.u_a = zak.u
  INNER JOIN a2230330u10 AS druh ON druh.ic = dv.ic_b AND druh.u = dv.u_b
  WHERE druh.a2518973u10 = 3
</g>